package org.yu.team2023.flashdays;

import net.minecraft.client.renderer.entity.EntityRenderers;
import net.minecraft.client.renderer.entity.LightningBoltRenderer;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.entity.MobCategory;
import net.minecraft.world.level.block.Blocks;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.event.entity.EntityAttributeCreationEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLClientSetupEvent;
import net.minecraftforge.fml.javafmlmod.FMLJavaModLoadingContext;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import org.yu.team2023.flashdays.client.render.*;
import org.yu.team2023.flashdays.entity.*;

public class ModEntities {
    private static final DeferredRegister<EntityType<?>> ENTITY_DEFERRED_REGISTER=DeferredRegister.create(ForgeRegistries.ENTITY_TYPES,FlashDays.MODID);
      public static final RegistryObject<EntityType<DamageHuman>> DAMAGE_HUMAN =ENTITY_DEFERRED_REGISTER.register("damage_human",()->EntityType.Builder.of(DamageHuman::new, MobCategory.CREATURE).sized(1, 1.85f).clientTrackingRange(10).build("damage_human"));

    public static void init(){
        FMLJavaModLoadingContext.get().getModEventBus().addListener(ModEntities::onAttributeCreator);
        ENTITY_DEFERRED_REGISTER.register(FMLJavaModLoadingContext.get().getModEventBus());
    }

    private static void onAttributeCreator(EntityAttributeCreationEvent event){
        event.put(DAMAGE_HUMAN.get(),DamageHuman.createAttributes().build());
    }
    @Mod.EventBusSubscriber(value = Dist.CLIENT,bus = Mod.EventBusSubscriber.Bus.MOD,modid = FlashDays.MODID)
    public static class ClientInit{
        @SubscribeEvent
        public static void onFMLClientSetup(FMLClientSetupEvent event){
            event.enqueueWork(() -> {
                EntityRenderers.register(DAMAGE_HUMAN.get(), DamageHumanRenderer::new);
            });
        }
    }
}
